package day_2022_12_to_3.year2023;

/**
 * @author haomin
 * @date 2023/02/12 20:09
 **/
public class Day2_12_Num1138 {
    class Solution {
        public String alphabetBoardPath(String target) {
            StringBuilder ans = new StringBuilder();
            int i = 0, j = 0;
            for (int k = 0; k < target.length(); ++k) {
                int v = target.charAt(k) - 'a';
                int x = v / 5, y = v % 5;
                while (j > y) {
                    --j;
                    ans.append('L');
                }
                while (i > x) {
                    --i;
                    ans.append('U');
                }
                while (j < y) {
                    ++j;
                    ans.append('R');
                }
                while (i < x) {
                    ++i;
                    ans.append('D');
                }
                ans.append("!");
            }
            return ans.toString();
        }
    }
}